package com.book.controller;

import com.book.model.entity.PointsRecords;
import com.book.service.PointsRecordsService;
import com.book.util.BaseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 积分记录表 前端控制器
 * </p>
 *
 * @author auto
 * @since 2025-04-02 06:38:55
 */
@RestController
@RequestMapping("/points-records")
@Tag(name = "积分记录表", description = "积分记录表相关接口")
public class PointsRecordsController {


    @Autowired
    private PointsRecordsService pointsRecordsService;
    @ApiOperation(value = "查询用户积分记录")
    @GetMapping("/list/{type}/{userId}")
    public BaseResult<?> getPointsRecordsListByUserId(@PathVariable ("type") Integer type,@PathVariable("userId") String userId) {
        return BaseResult.successResult(pointsRecordsService.getPointsRecordsListByUserId(type,userId));
    }

    @ApiOperation(value = "查询用户积分记录")
    @GetMapping("/list/{userId}")
    public BaseResult<?> getPointsRecordsListByUserId(@PathVariable("userId") String userId) {
        return BaseResult.successResult(pointsRecordsService.getPointsRecordsListByUserId(null,userId));
    }

    @ApiOperation(value = "用户签到")
    @GetMapping("/sign/{userId}")
    public BaseResult<?> userSignArrive(@PathVariable ("userId") String userId) {
        return BaseResult.successResult(pointsRecordsService.userSignArrive(userId));
    }

    @ApiOperation(value = "查询用户有没有签到")
    @GetMapping("/checkSign/{userId}")
    public BaseResult<?> checkSign(@PathVariable ("userId") String userId) {
        return BaseResult.successResult(pointsRecordsService.checkSign(userId));
    }

    @ApiOperation(value = "为用户发放积分")
    @PostMapping("/add")
    public BaseResult<?> addPoints(@RequestBody PointsRecords pointsRecords) {
        return BaseResult.successResult(pointsRecordsService.pushPoints(pointsRecords));
    }
}
